package com.smallrig.mall.template.huawei;

import java.util.ArrayList;
import java.util.List;

public class 基站维修 {

    static int[][] sites = new int[][]{{0,2,1},{1,0,2},{2,1,0}};

    static int min = Integer.MAX_VALUE;

    public static void main(String[] args) {
        for(int i=1;i<sites.length;i++){

            List<Integer> path = new ArrayList<>();
            path.add(0);
            dfs(i,sites[0][i],path);
        }
        System.out.println(min);

    }

    public static void dfs(int idx,int sum,List<Integer> path){
        if(path.size()== sites.length){
            min = Math.min(min,sum+sites[idx][0]);
            return;
        }

        for(int i=1;i<sites.length;i++){
            if(path.contains(i)){
                continue;
            }
            path.add(i);
            dfs(i,sum+sites[idx][i],path);
            path.remove(path.size()-1);
        }
    }

}
